package com.meij.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.amap.api.location.AMapLocation;
import com.anno.ActionBarSet;
import com.anno.ActionBarSet.WAY;
import com.meij.MJApplaction;
import com.meij.R;
import com.meij.activity.user.LoginActivity;
import com.meij.activity.user.RegistActivity;
import com.meij.activity.user.UserCenterActivity;
import com.meij.http.Url;
import com.meij.util.Info;

@ActionBarSet(title = "临时页面", way = WAY.TITLE)
public class TempActivity extends MjActivity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_temp);
	}

	@Override
	protected void onResume() {
		super.onResume();
		editLoginInfo();
	}

	private void editLoginInfo() {
		if (Info.isLogin()) {
			aq.id(R.id.textView1).text("已登录");
		} else {
			aq.id(R.id.textView1).text("未登录");
		}
	}

	public void btn0(View view) {
		Intent intent = new Intent(this, LoginActivity.class);
		startActivity(intent);
	}

	public void btn1(View view) {
		Intent intent = new Intent(this, RegistActivity.class);
		startActivity(intent);
	}

	public void btn6(View view) {
		Intent intent = new Intent(this, MainActivity.class);
		startActivity(intent);
	}

	public void btn7(View view) {
		if (Info.isLogin()) {
			Intent intent = new Intent(this, UserCenterActivity.class);
			intent.putExtra("id", MJApplaction.userInfo.getUserkey());
			startActivity(intent);
		} else {
			Toast("请先登录");
		}
	}

	public void btn8(View view) {

	}

	@Override
	public void onLocationChanged(AMapLocation location) {
		super.onLocationChanged(location);
		if (Info.isLogin()) {
			String url = Url.location + "?userkey=" + MJApplaction.userInfo.getUserkey() + "&lat=" + latitude + "&lng=" + longitude;
			getJson(url);
		}
	}
}
